PHP

How to demonstrate the json_encode() function with multi-dimensional array in PHP | PHP program

How to demonstrate the json_encode() function with multi-dimensional array in PHP | PHP program

How to demonstrate the json_encode() function with multi-dimensional array in PHP | PHP program

We will create a multi-dimensional array that contains the employee records and then convert the array into JSON format using json_encode() function.

<?php
//PHP program to demonstrate the json_encode() function 
//with multi-dimensional array.
$Emps = array(
    array(
        101,
        "RAJEEV",
        5000
    ) ,
    array(
        102,
        "KUNAL",
        7000
    ) ,
    array(
        103,
        "VIVEK",
        8000
    )
);

$jsonStr = json_encode($Emps);
printf("Result: %s<br>", $jsonStr);

?>
TutorialsLink Curator

This is an official account managed by the team TutorialsLink Community